﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using System.Windows.Media.Animation;
using System.Windows.Media.Media3D;
using System.Collections;
using CrazyWorship1.Creators;

namespace CrazyWorship1
{
    /// <summary>
    /// Interaction logic for Viewer.xaml
    /// </summary>
    public partial class Viewer : UserControl
    {
        public Viewer()
        {
            InitializeComponent();
         //   this.IsHitTestVisible = false;
            
        }
       
        public State CurrentState
        {
            get
            {
                return _currentState;
            }
            set
            {
                _currentState = value;
             
                _currentState.OnSongChanged += new EventHandler(_currentState_OnSongChanged);
            }
        }
        CreateAllBase creator;
        void _currentState_OnSongChanged(object sender, EventArgs e)
        {
            creator = (CreateAllBase)CurrentState.GetCreator(CurrentState.CurrentSong.CreatorApp);
            creator.OnCreatorDone += new EventHandler(creator_OnCreatorDone);
            creator.CurrentState=CurrentState;
            creator.StartSong();
            

        }

        void creator_OnCreatorDone(object sender, EventArgs e)
        {
            CurrentState.StartNextSong();
            creator = (CreateAllBase)CurrentState.GetCreator(CurrentState.CurrentSong.CreatorApp);
            creator.OnCreatorDone += new EventHandler(creator_OnCreatorDone);
            creator.CurrentState = CurrentState;
            creator.StartSong();
        }
        
  

        State _currentState;
    }
   
    

}
